var that,
  api = new (require('../../utils/api.js')),
  headimg = api.getimgurl(),
  app = getApp(),
  util = new (require('../../utils/util.js'));
Page({

  /**
   * 页面的初始数据
   */
  data: {
    star:5,
    assess:'',
    word:'无可挑剔'
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
that = this;
let {num} = options;
if(num){
  that.setData({ordernum:options.num})
}
  },

  star(e){
    let { i } = e.currentTarget.dataset,word='';
    i = Number(i);
    word = i == 1 ? '很差' : i == 2 ? '一般' : i == 3 ? '满意' : i == 4 ? '非常满意' :'无可挑剔'
    // switch (Number(i)){
    //   case 1: { word = "很差"}
    //   case 2: { word = "一般"}
    //   case 3: { word = "满意"}
    //   case 4: { word = "非常满意"}
    //   case 5: { word = "无可挑剔"}
    // }
    that.setData({ star: i, word})
  },
  input(e){
    that.setData({
      [e.currentTarget.dataset.prop]:e.detail.value
    })
  },
  save(){
    that.setData({btnloading:!0})
    let{star,assess,ordernum} = that.data
    // if(assess==''){
    //   wx.showModal({
    //     title: '提示',
    //     showCancel:!1,
    //     content:"请输入评价详情"
    //   })
    //   return;
    // }
    let data={star,assess,ordernum};
    api.userassess(data,res=>{
      that.setData({btnloading:!1})
      if(res.data.issuccess==1){
        util.nocancelmodal('提交成功！',"",res=>{
          let page = getCurrentPages();
          page=page[page.length-2];
          page.setData({needfresh:!0},()=>{
            wx.navigateBack() 
          })
          })
      }else{
        util.nocancelmodal(res.data.msg)
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})